﻿using System;
using System.Web.UI.WebControls;
using BLL;

public partial class ProductPackage_NSNPrint_Print28 : System.Web.UI.Page
{
    private PackageProduct pp;
    private static string sN3BK;

    public ProductPackage_NSNPrint_Print28()
    {
        pp = new PackageProduct();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        sN3BK = this.TextBox1.Text.Trim();
        string[] ppSNs = pp.GetPackageProductSNsforPrint(sN3BK, 28);
        if (ppSNs.Length == 28)
        {
            for (int i = 0; i < 28; i++)
            {
                ((Label)this.Page.FindControl("Label" + (2 * i + 1).ToString())).Text = ppSNs[i];
                ((Label)this.Page.FindControl("Label" + (2 * i + 2).ToString())).Text = "*" + ppSNs[i] + "*";
            }
        }
        else
        {
            string str = "已包装未打印外箱标签的产品数量不够28个，无法生成打印！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
        }
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(this.Label1.Text) || string.IsNullOrEmpty(sN3BK))
        {
            string str = "请先生成打印页面，再确认已打印外箱标签的条码！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
        }
        else
        {
            if (pp.SetPackageProductSNsPrinted(sN3BK, 28))
            {
                string str = "确认成功！";
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
            }
            else
            {
                string str = "确认失败，请联系相关人员！";
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
            }
        }
    }
}
